package com.soledroid;

public class LunchTime {
	private boolean slot[] = new boolean[5];
	private int currentLunchTime = 13;

	public LunchTime() {
		for(int i = 0; i < 5; i++) {
			slot[i] = true;
		}
	}

	public void Update(int start, int end) {
		if(start >= 11 && start <= 15) {
			slot[start-11] = false;
		}

		if(end >= 12 && end <= 16) {
			slot[end-12] = false;
		}

		if(end - start > 1) {
			for(int i = start+1; i < end; i++) {
				if(i-11 >= 0 && i-11 <= 4) {
					slot[i-11] = false;
				}
			}
		}

		if(!slot[2]) {
			for(int i = 0; i < 5; i++) {
				if(slot[i]) {
					currentLunchTime = i + 11;
					break;
				}
			}
		}
	}

	public int getLunchTime() {
		return currentLunchTime;
	}
}
